package com.yanqu.road.logic.bussiness.player;

import com.yanqu.road.entity.manor.*;
import com.yanqu.road.entity.player.PatronsFishBindingData;
import com.yanqu.road.logic.bussiness.DaoHelper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：zfr
 * @date ：2021/10/14 10:42
 */
public class UserFishPondBusiness {
    public static FishPondData getFishPondData(long playerId) {
        return DaoHelper.getUserFishPondDataDaoImpl().getUserFishPondData(playerId);
    }

    public static boolean addFishPondData(FishPondData data) {
        return DaoHelper.getUserFishPondDataDaoImpl().add(data);
    }

    public static boolean updateFishPondData(FishPondData data) {
        return DaoHelper.getUserFishPondDataDaoImpl().update(data);
    }

    public static Map<Integer, FishData> getFishDataMap(long playerId) {
        Map<Integer, FishData> fishDataMap = DaoHelper.getUserFishPondFishDataDaoImpl().getFishDataMap(playerId);
        for (FishData fishData : fishDataMap.values()) {
            fishData.setFishSkillDataMap(DaoHelper.getUserFishPondFishSkillDataDaoImpl().getFishSkillDataMap(playerId, fishData.getFishId()));
        }
        return fishDataMap;
    }

    public static Map<Integer, FishData> getFishDataMap(long playerId, int patronsId) {
        Map<Integer, FishData> resultMap = new HashMap<>();
        Map<Integer, FishData> fishDataMap = DaoHelper.getUserFishPondFishDataDaoImpl().getFishDataMap(playerId);
        for (FishData fishData : fishDataMap.values()) {
            if(fishData.getEquipPatronsId() == patronsId) {
                resultMap.put(fishData.getFishId(), fishData);
                fishData.setFishSkillDataMap(DaoHelper.getUserFishPondFishSkillDataDaoImpl().getFishSkillDataMap(playerId, fishData.getFishId()));
                break;
            }
        }
        return resultMap;
    }

    public static Map<Long,Map<Integer, FishData>> getSomeFishDataMap(List<Long> userIdList) {
        Map<Long,Map<Integer, FishData>> fishDataMap = DaoHelper.getUserFishPondFishDataDaoImpl().getSomeFishDataMap(userIdList);
        return fishDataMap;
    }

    public static boolean addFishData(FishData data) {
        return DaoHelper.getUserFishPondFishDataDaoImpl().add(data);
    }

    public static boolean updateFishData(FishData data) {
        return DaoHelper.getUserFishPondFishDataDaoImpl().update(data);
    }

    public static boolean addFishSkillData(FishSkillData data) {
        return DaoHelper.getUserFishPondFishSkillDataDaoImpl().add(data);
    }

    public static boolean updateFishSkillData(FishSkillData data) {
        return DaoHelper.getUserFishPondFishSkillDataDaoImpl().update(data);
    }

    public static Map<Integer, FishPondSpecialItemData> getFishPondSpecialItemDataMap(long playerId) {
        return DaoHelper.getUserFishPondSpecialItemDataDaoImpl().getFishPondSpecialItemDataMap(playerId);
    }

    public static boolean addSpecialItemData(FishPondSpecialItemData data) {
        return DaoHelper.getUserFishPondSpecialItemDataDaoImpl().add(data);
    }

    public static boolean updateSpecialItemData(FishPondSpecialItemData data) {
        return DaoHelper.getUserFishPondSpecialItemDataDaoImpl().update(data);
    }

    public static List<FishPondTaskData> getFishPondTaskDataList(long playerId) {
        return DaoHelper.getUserFishPondTaskDataDaoImpl().getFishPondTaskDataList(playerId);
    }

    public static boolean addFishPondTaskData(FishPondTaskData data) {
        return DaoHelper.getUserFishPondTaskDataDaoImpl().add(data);
    }

    public static boolean updateFishPondTaskData(FishPondTaskData data) {
        return DaoHelper.getUserFishPondTaskDataDaoImpl().update(data);
    }

    public static boolean addPatronsFishBinding(PatronsFishBindingData data) {
        return DaoHelper.getPatronsFishBindingDaoImpl().add(data);
    }

    public static boolean updatePatronsFishBinding(PatronsFishBindingData data) {
        return DaoHelper.getPatronsFishBindingDaoImpl().update(data);
    }

    public static Map<Integer, PatronsFishBindingData> getPatronsFishBindingData(long userId) {
        return DaoHelper.getPatronsFishBindingDaoImpl().getPatronsVehicleBindingData(userId);
    }
}
